﻿using CollegeReviewApp.DataModels;
using CollegeReviewApp.Web.IDataAdapters.Adapters;
using CollegeReviewApp.Web.IDataAdapters.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace CollegeReviewApp.Web.Controllers
{
    public class ReviewsController : ApiController
    {
        ICollegeReviewAdapter _adapter = new CollegeReviewAdapter();
        public IHttpActionResult GET(int id)
        {
            //returns all reviews for college
            return Ok(_adapter.GetAllReviews(id));
        }
        public IHttpActionResult POST(Review review)
        {
            //Create a review in db
            return Ok(_adapter.AddReview(review));//returns the ID of REVIEW
        }
        public IHttpActionResult PUT(Review review)
        {
            //update a review
            return Ok(_adapter.UpdateReview(review));
        }
        public IHttpActionResult DELETE(int id)
        {
            //Delete a review
            _adapter.DeleteReview(id);
            return Ok();
        }
    }
}
